<!doctype html>
<html lang="en">

	<head>
		<meta charset="UTF-8" />
		<title>选项卡</title>
		<link rel="stylesheet" type="text/css" href="css/style.css" />
	</head>

	<body>
		<div class="built-in-app">
			<ul class="nav">
				<li class="active">公告</li>
				<li>规则</li>
				<li>论坛</li>
				<li>安全</li>
				<li>公益</li>
			</ul>
			<div class="main">
				<div class="active">
					<p style="color: #ff5000;">天猫618狂欢冲刺 聚划算全面爆发</p>
					<p style="display: inline-block;">天猫 618 吃货大爆发 </p>
					<p style="display: inline-block;padding-left: 20px;">新西兰高端奶成交大涨</p>
				</div>
				<div>
					<a href="#">新增《淘宝网汽配行业</a>
					<a href="#" style="padding-right: 275px;">《淘宝网区域零售服务</a>
					<a href="#">《淘宝网票务行业管理</a>
					<a href="#">《淘宝网数字娱乐市场</a>
				</div>
				<div>
					<a href="#">淘宝1212活动招商</a>
					<a href="#" style="padding-right: 400px;">中差评功能升级</a>
					<a href="#">陌生人拼团上线</a>
					<a href="#">运营神器年中大促</a>
				</div>
				<div>
					<a href="#">魔豆妈妈公益项目</a>
					<a href="#" style="padding-right: 400px;">让母爱永不打烊！</a>
					<a href="#">卖家注意：风险通报！</a>
					<a href="#">售假获刑又起诉！</a>
				</div>
				<div>
				<a href="#">淘宝公益平台正式更名</a>
					<a href="#" style="padding-right: 275px;">益起来商家招募即将截止</a>
					<a href="#">卖家如何设置公益宝贝</a>
					<a href="#">公益机构开店全攻略</a>
				</div>
			</div>
		</div>
		<script type="text/javascript">
			var nav = document.querySelectorAll(".nav > li");
			var main = document.querySelectorAll(".main > div");

			for(var i = 0; i < nav.length; i++) {
				nav[i].index = i;
				nav[i].addEventListener('mouseover', function() {
					for(var k = 0; k < nav.length; k++) {
						nav[k].classList.remove('active');
						main[k].classList.remove('active');
					}
					this.classList.add('active');
					console.log(this.index);
					main[this.index].classList.add('active');
				})
			}
		</script>
	</body>

</html>